import { BasicColumn, FormSchema } from '/@/components/Table';
// 表格字段
export const columns: BasicColumn[] = [
  {
    title: '大楼名称',
    dataIndex: 'buildingName',
  },
  {
    title: '区域位置',
    dataIndex: 'area',
  },
  {
    title: '地址',
    dataIndex: 'address',
  },
  {
    title: '最低租金',
    dataIndex: 'minRentMoney',
  },
  {
    title: '添加时间',
    dataIndex: 'createTime',
  },
  {
    title: '状态',
    dataIndex: 'status',
  },
  {
    title: '是否置顶',
    dataIndex: 'isTopping',
  },
  {
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
    width: 160,
  },
];
// 表单
export const searchFormSchema: FormSchema[] = [
  {
    field: 'buildingName',
    label: '大楼名称',
    component: 'Input',
    colProps: { span: 5 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'area',
    label: '区域',
    colProps: { span: 5 },
    component: 'Cascader',
    componentProps: {
      placeholder: '请选择',
      options: [
        {
          value: 'zhejiang',
          label: 'Zhejiang',
          children: [
            {
              value: 'hangzhou',
              label: 'Hangzhou',
            },
          ],
        },
        {
          value: 'jiangsu',
          label: 'Jiangsu',
          children: [
            {
              value: 'nanjing',
              label: 'Nanjing',
            },
          ],
        },
      ],
    },
  },
  {
    field: 'status',
    label: '状态',
    component: 'Select',
    componentProps: {
      placeholder: '请选择',
      options: [
        { label: '已上线', value: '已上线' },
        { label: '已下线', value: '已下线' },
      ],
    },
    colProps: { span: 5 },
  },
  {
    field: 'isTopping',
    label: '是否置顶',
    component: 'Select',
    componentProps: {
      placeholder: '请选择',
      options: [
        { label: '是', value: '是' },
        { label: '否', value: '否' },
      ],
    },
    colProps: { span: 5 },
  },
];

// 表格数据
export const dataSource = [
  {
    id: 1,
    buildingName: 'SKY',
    area: '纽约/曼哈顿',
    address: '67 Mott St, New York, NY 10013',
    minRentMoney: '$2000/月',
    createTime: '2021-5-20 13:20:20',
    status: '已上线',
    isTopping: '是',
    // redBook: 'ZAN@123.com',
    // instargran: 'ZAN@123.com',
    seoTitle: 'seo标题',
    seoDesc: 'seo描述',
    seoKeyWord: 'seo关键字',
    seoUrl: 'seo-URL',
    pic: 'pic-URL',
    remark: '简介',
  },
  {
    id: 2,
    buildingName: 'SKY',
    area: '纽约/曼哈顿',
    address: '67 Mott St, New York, NY 10013',
    minRentMoney: '$2000/月',
    createTime: '2021-5-20 13:20:20',
    status: '已上线',
    isTopping: '是',
    seoTitle: 'seo标题',
    seoDesc: 'seo描述',
    seoKeyWord: 'seo关键字',
    seoUrl: 'seo-URL',
    pic: 'pic-URL',
    remark: '简介',
  },
];

export const getAccountList = () => {
  return dataSource;
};

export const buildingFormSchema: FormSchema[] = [
  {
    field: 'buildingName',
    label: '大楼名称',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          message: '请输入大楼名称',
        },
      ];
    },
  },
  {
    field: 'detailAddr',
    label: '详细地址',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          message: '请输入详细地址',
        },
      ];
    },
  },
  {
    field: 'area',
    label: '区域位置',
    component: 'Input',
    colProps: { span: 24 },
    slot: 'areaSlot',
    dynamicRules: () => {
      return [
        {
          required: true,
          message: '请选择区域位置',
        },
      ];
    },
  },
  {
    field: 'minRentMoney',
    label: '最低租金',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'school',
    label: '学校',
    component: 'Select',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请选择',
      options: [
        { label: '哈佛大学', value: '哈佛大学' },
        { label: '牛津大学', value: '牛津大学' },
      ],
    },
  },
  {
    field: 'supportingOfOwner',
    label: '业主配套特点(选填)',
    component: 'Select',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '可多选',
      mode: 'multiple',
      options: [
        { label: '哈佛大学', value: '哈佛大学' },
        { label: '牛津大学', value: '牛津大学' },
      ],
    },
  },
  {
    field: 'supportingOfHouse',
    label: '房屋配置特点(选填)',
    component: 'Select',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '可多选',
      mode: 'multiple',
      options: [
        { label: '哈佛大学', value: '哈佛大学' },
        { label: '牛津大学', value: '牛津大学' },
      ],
    },
  },
  {
    label: '大楼简介',
    field: 'remark',
    component: 'InputTextArea',
    componentProps: {
      rows: 4,
      placeholder: '请输入',
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          message: '请输入简介',
        },
      ];
    },
  },
  {
    label: '添加封面图',
    field: 'coverUrl',
    component: 'Upload',
    slot: 'coverUrlSlot',
    rules: [
      {
        required: true,
        validator: async (_rule, value) => {
          if (!value) {
            /* eslint-disable-next-line */
            return Promise.reject('请添加首图');
          }
          return Promise.resolve();
        },
        trigger: 'change',
      },
    ],
  },
  {
    field: 'otherPic',
    label: '添加其他图片',
    component: 'Upload',
    componentProps: {
      api: () => {},
      accept: ['jpg', 'jepg', 'png', 'jpeg', 'JPG', 'PNG', 'JEPG', 'JPEG'],
      maxSize: 5,
    },
  },
  {
    label: '',
    field: 'insert',
    component: 'Input',
    slot: 'buttonSlot',
  },
  {
    field: 'seoTitle',
    label: 'SEO标题',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'seoDesc',
    label: 'SEO描述',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'seoKeyWord',
    label: 'SEO关键字',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'seoUrl',
    label: 'SEO-URL',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'pic',
    label: '图片ALT',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
  },
];
